﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Subjects;
using System.Text;
using Frogs.Stability.CircuitBreaker.Exceptions;

namespace Frogs.Stability.CircuitBreaker.Behaviors.Functions
{
    class OpenBehavior : IFunctionCircuitBehavior
    {
        public T DoFunction<T>(Func<T> func)
        {
			this._executionResult.OnNext(Behaviors.ExecutionResult.Fail);
            throw new OpenCircuitBreakerException();
        }

        public CircuitState GetStatus()
        {
            return CircuitState.Open;
        }

		Subject<ExecutionResult> _executionResult = new Subject<ExecutionResult>();
		public IObservable<ExecutionResult> ExecutionResult { get { return this._executionResult; } }
    }
}
